/**
 * 
 */
package com.zznode.redsun.commons.sercurity.shiro;

import com.zznode.redsun.commons.sercurity.model.Account;

/**
 * @author taoping
 * 
 */
public final class LoginUserBuilder {

	private Account account;

	public LoginUserBuilder(Account account) {
		this.account = account;
	}

	public LoginUser<Long> build() {
		return new LoginUserImpl(account);
	}

	public static class LoginUserImpl implements LoginUser<Long> {
		private Long accountId;
		private Long userId;
		private String loginName;
		private String realName;

		private LoginUserImpl(Account account) {
			this.accountId = account.getId();
			this.userId = account.getUserId();
			this.loginName = account.getCode();
			this.realName = account.getName();
		}

		@Override
		public Long getAccountId() {
			return accountId;
		}

		@Override
		public Long getUserId() {
			return userId;
		}

		@Override
		public String getLoginName() {
			return loginName;
		}

		@Override
		public String getRealName() {
			return realName;
		}

		@Override
		public String toString() {
			return this.loginName;
		}
	}
}
